package com.business.socialcredit;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.ConvertUtils;

import com.frame.struts.ActionContext;
import com.frame.struts.BaseBean;
import com.utils.CommUtil;
import com.utils.DateConverter;

public class XwmtxxplForm extends BaseBean
{
    public XwmtxxplForm()
    {
    }
    
    static{
        ConvertUtils.register(new DateConverter(), Date.class);
    }

    XwmtxxplEntity xwmtxxplEntity = new XwmtxxplEntity();
    private String oldId="";

    public String addXwmtxxpl()
    {
        if( logger.isDebugEnabled() )
        {
            logger.debug( "enter addXwmtxxpl()" );
        }
        HttpServletRequest request = ActionContext.getActionContext()
                                                  .getRequest();
        HttpServletResponse response = ActionContext.getActionContext()
                                                    .getResponse();
        SocialCreditFactory factory = SocialCreditFactory.getInstance();
        String qyid = (String) request.getSession()
                                      .getAttribute( "session_qyid" );
        xwmtxxplEntity.setQyid( qyid );
        xwmtxxplEntity.setOptdate( new Date() );
        xwmtxxplEntity.setOptrid( CommUtil.getUserId( request ) );
        xwmtxxplEntity.setXh( SocialCreditFactory.getNextXh( "qy_xwmtxxpl", qyid ) );
        try
        {
            if( factory.addXwmtxxpl( xwmtxxplEntity ) )
            {
                System.out.println( "Enter addXwmtxxpl()" );
                response.sendRedirect( "/socialcredit/queryxwmtxxpl.jsp" );
            }else{
                response.sendRedirect( "/failed.jsp" );
            }
        }
        catch( Exception e )
        {
        }
        return null;

    }

    public String editXwmtxxpl()
    {
        if( logger.isDebugEnabled() )
        {
            logger.debug( "enter addXwmtxxpl()" );
        }
        HttpServletRequest request = ActionContext.getActionContext()
                                                  .getRequest();
        HttpServletResponse response = ActionContext.getActionContext()
                                                    .getResponse();
        SocialCreditFactory factory = SocialCreditFactory.getInstance();
        String qyid = (String) request.getSession()
                                      .getAttribute( "session_qyid" );
        xwmtxxplEntity.setQyid( qyid );
        xwmtxxplEntity.setOptdate( new Date() );
        xwmtxxplEntity.setOptrid( CommUtil.getUserId( request ) );
        factory.delXwmtxxpl(qyid,xwmtxxplEntity.getXh());
        try
        {
            if( factory.addXwmtxxpl( xwmtxxplEntity ) )
            {
                System.out.println( "Enter editXwmtxxpl()" );
                response.sendRedirect( "/socialcredit/queryxwmtxxpl.jsp" );
            }else{
                response.sendRedirect( "/failed.jsp" );
            }
        }
        catch( Exception e )
        {
            e.printStackTrace();
        }
        return null;
    }
    
    public String getOldId(){
        return this.oldId;
    }
    public void setOldId(String oldId){
        this.oldId=oldId;
    }
    
    public String getQyid()
    {
        return xwmtxxplEntity.getQyid();
    }

    public void setQyid( String qyid )
    {
        xwmtxxplEntity.setQyid(qyid);
    }

    public int getXh()
    {
        return xwmtxxplEntity.getXh();
    }

    public void setXh( int xh )
    {
        xwmtxxplEntity.setXh( xh );
    }

    public String getOptrid()
    {
        return xwmtxxplEntity.getOptrid();
    }

    public void setOptrid( String optrid )
    {
        xwmtxxplEntity.setOptrid( optrid );
    }

    public Date getOptdate()
    {
        return xwmtxxplEntity.getOptdate();
    }

    public void setOptdate( Date optdate )
    {
        xwmtxxplEntity.setOptdate( optdate );
    }

    public String getRecstate()
    {
        return xwmtxxplEntity.getRecstate();
    }

    public void setRecstate( String recstate )
    {
        xwmtxxplEntity.setRecstate( recstate );
    }

    public String getRemark()
    {
        return xwmtxxplEntity.getRemark();
    }

    public void setRemark( String remark )
    {
        xwmtxxplEntity.setRemark( remark );
    }

    public String getNrms()
    {
        return xwmtxxplEntity.getNrms();
    }

    public void setNrms( String nrms )
    {
        xwmtxxplEntity.setNrms( nrms );
    }

    public String getPlly()
    {
        return xwmtxxplEntity.getPlly();
    }

    public void setPlly( String plly )
    {
        xwmtxxplEntity.setPlly( plly );
    }

    public java.sql.Date getPlsj()
    {
        return xwmtxxplEntity.getPlsj();
    }

    public void setPlsj( java.sql.Date plsj )
    {
        xwmtxxplEntity.setPlsj( plsj );
    }
}
